<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 默认选项
        let defaultOptions = {
            headers: {
                'Accept': '*/*',
                'Content-Type': 'application/json',
                'Cache-Control': 'no-cache'
            },
            method: 'GET'
        };
        // 用户选项
        let myOptions = {
            headers: {
                'token': 'EyxBFRXbtZIvByGpmsmmcMXaXKlwiVdh'
            },
            params: {
                'id': 13,
                'status': 2
            },
            method: 'POST'
        };

        // 使用 Object.assign() 进行合并
        let mergedOptionsObjectAssign = Object.assign({}, defaultOptions, myOptions);
        // 手动合并 headers 属性
        mergedOptionsObjectAssign.headers = Object.assign({}, defaultOptions.headers, myOptions.headers);

        console.log(mergedOptionsObjectAssign);


    </script>
</body>

</html>